Change-Id: I235c5beacce38e9121fb1db94ce410d010356fcf
* @see WANObjectCache::getWithSetCallback()
*
* @param IDatabase $db1
* @see WANObjectCache::getWithSetCallback()
*
* @param IDatabase $db1
- * @param IDatabase $dbs,...
+ * @param IDatabase $db2 [optional]
* @return array Map of values:
* - lag: highest lag of any of the DBs or false on error (e.g. replication stopped)
* - since: oldest UNIX timestamp of any of the DB lag estimates
* - pending: whether any of the DBs have uncommitted changes
* @return array Map of values:
* - lag: highest lag of any of the DBs or false on error (e.g. replication stopped)
* - since: oldest UNIX timestamp of any of the DB lag estimates
* - pending: whether any of the DBs have uncommitted changes
- public static function getCacheSetOptions( IDatabase $db1 ) {
+ public static function getCacheSetOptions( IDatabase $db1, IDatabase $db2 = null ) {
$res = [ 'lag' => 0, 'since' => INF, 'pending' => false ];
foreach ( func_get_args() as $db ) {
/** @var IDatabase $db */
$res = [ 'lag' => 0, 'since' => INF, 'pending' => false ];
foreach ( func_get_args() as $db ) {
/** @var IDatabase $db */
namespace Wikimedia\Rdbms;
use Wikimedia\ScopedCallback;
namespace Wikimedia\Rdbms;
use Wikimedia\ScopedCallback;
use RuntimeException;
use UnexpectedValueException;
use stdClass;
use RuntimeException;
use UnexpectedValueException;
use stdClass;
* comment (you can use __METHOD__ or add some extra info)
* @param bool $tempIgnore Whether to avoid throwing an exception on errors...
* maybe best to catch the exception instead?
* comment (you can use __METHOD__ or add some extra info)
* @param bool $tempIgnore Whether to avoid throwing an exception on errors...
* maybe best to catch the exception instead?
* @return bool|IResultWrapper True for a successful write query, IResultWrapper object
* for a successful read query, or false on failure if $tempIgnore set
* @return bool|IResultWrapper True for a successful write query, IResultWrapper object
* for a successful read query, or false on failure if $tempIgnore set
*/
public function query( $sql, $fname = __METHOD__, $tempIgnore = false );
*/
public function query( $sql, $fname = __METHOD__, $tempIgnore = false );
* @param string|array $join_conds The query join conditions. See IDatabase::select() for details.
*
* @return mixed The value from the field
* @param string|array $join_conds The query join conditions. See IDatabase::select() for details.
*
* @return mixed The value from the field
*/
public function selectField(
$table, $var, $cond = '', $fname = __METHOD__, $options = [], $join_conds = []
*/
public function selectField(
$table, $var, $cond = '', $fname = __METHOD__, $options = [], $join_conds = []
* @param string|array $join_conds The query join conditions. See IDatabase::select() for details.
*
* @return array The values from the field
* @param string|array $join_conds The query join conditions. See IDatabase::select() for details.
*
* @return array The values from the field
* @since 1.25
*/
public function selectFieldValues(
* @since 1.25
*/
public function selectFieldValues(
* [ 'page' => [ 'LEFT JOIN', 'page_latest=rev_id' ] ]
*
* @return IResultWrapper Resulting rows
* [ 'page' => [ 'LEFT JOIN', 'page_latest=rev_id' ] ]
*
* @return IResultWrapper Resulting rows
*/
public function select(
$table, $vars, $conds = '', $fname = __METHOD__,
*/
public function select(
$table, $vars, $conds = '', $fname = __METHOD__,
* @param array|string $join_conds Join conditions
*
* @return stdClass|bool
* @param array|string $join_conds Join conditions
*
* @return stdClass|bool
*/
public function selectRow( $table, $vars, $conds, $fname = __METHOD__,
$options = [], $join_conds = []
*/
public function selectRow( $table, $vars, $conds, $fname = __METHOD__,
$options = [], $join_conds = []
* @param string $fname Function name for profiling
* @param array $options Options for select
* @return int Row count
* @param string $fname Function name for profiling
* @param array $options Options for select
* @return int Row count
*/
public function estimateRowCount(
$table, $vars = '*', $conds = '', $fname = __METHOD__, $options = []
*/
public function estimateRowCount(
$table, $vars = '*', $conds = '', $fname = __METHOD__, $options = []
* @param array $options Options for select
* @param array $join_conds Join conditions (since 1.27)
* @return int Row count
* @param array $options Options for select
* @param array $join_conds Join conditions (since 1.27)
* @return int Row count
*/
public function selectRowCount(
$tables, $vars = '*', $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
*/
public function selectRowCount(
$tables, $vars = '*', $conds = '', $fname = __METHOD__, $options = [], $join_conds = []
* @param string $field Filed to check on that table
* @param string $fname Calling function name (optional)
* @return bool Whether $table has filed $field
* @param string $field Filed to check on that table
* @param string $fname Calling function name (optional)
* @return bool Whether $table has filed $field
*/
public function fieldExists( $table, $field, $fname = __METHOD__ );
*/
public function fieldExists( $table, $field, $fname = __METHOD__ );
* @param string $index
* @param string $fname
* @return bool|null
* @param string $index
* @param string $fname
* @return bool|null
*/
public function indexExists( $table, $index, $fname = __METHOD__ );
*/
public function indexExists( $table, $index, $fname = __METHOD__ );
* @param string $table
* @param string $fname
* @return bool
* @param string $table
* @param string $fname
* @return bool
*/
public function tableExists( $table, $fname = __METHOD__ );
*/
public function tableExists( $table, $fname = __METHOD__ );
* @param array $options Array of options
*
* @return bool
* @param array $options Array of options
*
* @return bool
*/
public function insert( $table, $a, $fname = __METHOD__, $options = [] );
*/
public function insert( $table, $a, $fname = __METHOD__, $options = [] );
* - IGNORE: Ignore unique key conflicts
* - LOW_PRIORITY: MySQL-specific, see MySQL manual.
* @return bool
* - IGNORE: Ignore unique key conflicts
* - LOW_PRIORITY: MySQL-specific, see MySQL manual.
* @return bool
*/
public function update( $table, $values, $conds, $fname = __METHOD__, $options = [] );
*/
public function update( $table, $values, $conds, $fname = __METHOD__, $options = [] );
* @param array $rows Can be either a single row to insert, or multiple rows,
* in the same format as for IDatabase::insert()
* @param string $fname Calling function name (use __METHOD__) for logs/profiling
* @param array $rows Can be either a single row to insert, or multiple rows,
* in the same format as for IDatabase::insert()
* @param string $fname Calling function name (use __METHOD__) for logs/profiling
*/
public function replace( $table, $uniqueIndexes, $rows, $fname = __METHOD__ );
*/
public function replace( $table, $uniqueIndexes, $rows, $fname = __METHOD__ );
* Values with integer keys form unquoted SET statements, which can be used for
* things like "field = field + 1" or similar computed values.
* @param string $fname Calling function name (use __METHOD__) for logs/profiling
* Values with integer keys form unquoted SET statements, which can be used for
* things like "field = field + 1" or similar computed values.
* @param string $fname Calling function name (use __METHOD__) for logs/profiling
* @return bool
*/
public function upsert(
* @return bool
*/
public function upsert(
* @param array $conds Condition array of field names mapped to variables,
* ANDed together in the WHERE clause
* @param string $fname Calling function name (use __METHOD__) for logs/profiling
* @param array $conds Condition array of field names mapped to variables,
* ANDed together in the WHERE clause
* @param string $fname Calling function name (use __METHOD__) for logs/profiling
- * @throws DBUnexpectedError
*/
public function deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds,
$fname = __METHOD__
*/
public function deleteJoin( $delTable, $joinTable, $delVar, $joinVar, $conds,
$fname = __METHOD__
* @param string $fname Name of the calling function
* @throws DBUnexpectedError
* @return bool|IResultWrapper
* @param string $fname Name of the calling function
* @throws DBUnexpectedError
* @return bool|IResultWrapper
*/
public function delete( $table, $conds, $fname = __METHOD__ );
*/
public function delete( $table, $conds, $fname = __METHOD__ );
* IDatabase::select() for details.
*
* @return bool
* IDatabase::select() for details.
*
* @return bool
*/
public function insertSelect( $destTable, $srcTable, $varMap, $conds,
$fname = __METHOD__,
*/
public function insertSelect( $destTable, $srcTable, $varMap, $conds,
$fname = __METHOD__,
* Determines how long the server has been up
*
* @return int
* Determines how long the server has been up
*
* @return int
*/
public function getServerUptime();
*/
public function getServerUptime();
* @return int|null Zero if the replica DB was past that position already,
* greater than zero if we waited for some period of time, less than
* zero if it timed out, and null on error
* @return int|null Zero if the replica DB was past that position already,
* greater than zero if we waited for some period of time, less than
* zero if it timed out, and null on error
*/
public function masterPosWait( DBMasterPos $pos, $timeout );
/**
* Get the replication position of this replica DB
*
*/
public function masterPosWait( DBMasterPos $pos, $timeout );
/**
* Get the replication position of this replica DB
*
- * @return DBMasterPos|bool False if this is not a replica DB.
+ * @return DBMasterPos|bool False if this is not a replica DB
+ * @throws DBError
*/
public function getReplicaPos();
*/
public function getReplicaPos();
* Get the position of this master
*
* @return DBMasterPos|bool False if this is not a master
* Get the position of this master
*
* @return DBMasterPos|bool False if this is not a master
*/
public function getMasterPos();
*/
public function getMasterPos();
* Only set the flush flag if you are sure that these warnings are not applicable,
* and no explicit transactions are open.
*
* Only set the flush flag if you are sure that these warnings are not applicable,
* and no explicit transactions are open.
*
- * @throws DBUnexpectedError
*/
public function commit( $fname = __METHOD__, $flush = '' );
*/
public function commit( $fname = __METHOD__, $flush = '' );
* constant to disable warnings about calling rollback when no transaction is in
* progress. This will silently break any ongoing explicit transaction. Only set the
* flush flag if you are sure that it is safe to ignore these warnings in your context.
* constant to disable warnings about calling rollback when no transaction is in
* progress. This will silently break any ongoing explicit transaction. Only set the
* flush flag if you are sure that it is safe to ignore these warnings in your context.
- * @throws DBUnexpectedError
* @since 1.23 Added $flush parameter
*/
public function rollback( $fname = __METHOD__, $flush = '' );
* @since 1.23 Added $flush parameter
*/
public function rollback( $fname = __METHOD__, $flush = '' );
* useful to call on a replica DB after waiting on replication to catch up to the master.
*
* @param string $fname Calling function name
* useful to call on a replica DB after waiting on replication to catch up to the master.
*
* @param string $fname Calling function name
- * @throws DBUnexpectedError
* @since 1.28
*/
public function flushSnapshot( $fname = __METHOD__ );
* @since 1.28
*/
public function flushSnapshot( $fname = __METHOD__ );
* instead.
*
* @return int|bool Database replication lag in seconds or false on error
* instead.
*
* @return int|bool Database replication lag in seconds or false on error
*/
public function getLag();
*/
public function getLag();
* indication of the staleness of subsequent reads.
*
* @return array ('lag': seconds or false on error, 'since': UNIX timestamp of BEGIN)
* indication of the staleness of subsequent reads.
*
* @return array ('lag': seconds or false on error, 'since': UNIX timestamp of BEGIN)
* @since 1.27
*/
public function getSessionLagStatus();
* @since 1.27
*/
public function getSessionLagStatus();
*
* @param array $options
* @return void
*
* @param array $options
* @return void
*/
public function setSessionOptions( array $options );
*/
public function setSessionOptions( array $options );
* @param string $lockName Name of lock to poll
* @param string $method Name of method calling us
* @return bool
* @param string $lockName Name of lock to poll
* @param string $method Name of method calling us
* @return bool
* @since 1.20
*/
public function lockIsFree( $lockName, $method );
* @since 1.20
*/
public function lockIsFree( $lockName, $method );
* @param string $method Name of the calling method
* @param int $timeout Acquisition timeout in seconds
* @return bool
* @param string $method Name of the calling method
* @param int $timeout Acquisition timeout in seconds
* @return bool
*/
public function lock( $lockName, $method, $timeout = 5 );
*/
public function lock( $lockName, $method, $timeout = 5 );
* @param string $method Name of the calling method
*
* @return int Returns 1 if the lock was released, 0 if the lock was not established
* @param string $method Name of the calling method
*
* @return int Returns 1 if the lock was released, 0 if the lock was not established
- * by this thread (in which case the lock is not released), and NULL if the named
- * lock did not exist
+ * by this thread (in which case the lock is not released), and NULL if the named lock
+ * did not exist
+ *
+ * @throws DBError
*/
public function unlock( $lockName, $method );
*/
public function unlock( $lockName, $method );
* @param string $fname Name of the calling method
* @param int $timeout Acquisition timeout in seconds
* @return ScopedCallback|null
* @param string $fname Name of the calling method
* @param int $timeout Acquisition timeout in seconds
* @return ScopedCallback|null
- * @throws DBUnexpectedError
* @since 1.27
*/
public function getScopedLockAndFlush( $lockKey, $fname, $timeout );
* @since 1.27
*/
public function getScopedLockAndFlush( $lockKey, $fname, $timeout );